import { setLocal, getLocal, deleteLocal } from 'storage-sync-lite'

import { STORAGE_PREFIX } from './config'

const useSessionStorage = (key, options) => {
  const keyStr = `${STORAGE_PREFIX}${key}`
  const set = (value) => {
    setLocal(keyStr, value, options)
  }

  const get = () => {
    return getLocal(keyStr)
  }

  const remove = () => {
    return deleteLocal(keyStr)
  }

  return { set, get, remove }
}

export default useSessionStorage
